<?php
declare(strict_types=1);

namespace Service\MessageService;
use Service\BaseService;
use Hyperf\Amqp\Producer;
use Service\Code\Normal;
use App\Amqp\Producer\PayDeclareMessageProducer;

/**
 * 支付单申报服务中心
 * @author chenshubo
 */
class PayDeclareMessageService extends BaseService
{
    /**
     * 发布消息队列
     * @param array $msg
     */
    public function publishMsg( array $msg  = [] )
    {
        try {
            $handlerMessage = new PayDeclareMessageProducer($msg);
            $producer = container()->get(Producer::class);
            $result = $producer->produce($handlerMessage,true);
            if( $result ) {
                return Normal::returnCode(Normal::SUC,"发布成功");
            }
            return Normal::returnCode(Normal::FAIL,"操作失败，请稍微再试[100000]");
        } catch ( \Throwable $e ) {
            return Normal::returnCode(Normal::FAIL,"操作失败，请稍微再试[{$e->getMessage()},{$e->getLine()},{$e->getFile()}]");
        }
    }
}